package cn.iocoder.devlop.module.annual.report.common.service;

import cn.hutool.core.lang.Dict;
import cn.iocoder.devlop.module.annual.report.entuser.controller.vo.EntuserUpdateReqVO;
import cn.iocoder.devlop.module.annual.report.entuser.service.EntuserService;
import cn.iocoder.devlop.module.annual.report.enums.ChangeInfoNotificationEnum;
import cn.iocoder.devlop.module.annual.report.marpripinfo.controller.vo.MarpripinfoBaseVO;
import cn.iocoder.devlop.module.annual.report.marpripinfo.service.MarpripinfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author Euan
 * @since 2024/1/19
 */
@Service
@RequiredArgsConstructor
public class SyncInfoService {

    private final EntuserService entuserService;

    private final MarpripinfoService marpripinfoService;

    public void syncNotification(ChangeInfoNotificationEnum.Type type, ChangeInfoNotificationEnum.Target target, Dict data) {

        switch (target) {
            case T_BASEINFO_2013:
            case T_BASEINFO_2023:
//                BaseinfoBaseVO bean = (BaseinfoBaseVO) data.toBean(target.getCls());
//                if (type == ChangeInfoNotificationEnum.Type.INSERT) {
//                    baseinfoService.createBaseinfo(bean);
//                } else {
//                    baseinfoService.updateBaseinfo(bean);
//                }
                break;
            case T_WS_BASEINFO_2013:
            case T_WS_BASEINFO_2023:
//                WsBaseinfoBaseVO wsBaseinfoBaseVO = (WsBaseinfoBaseVO) data.toBean(target.getCls());
//                if (type == ChangeInfoNotificationEnum.Type.INSERT) {
//                    wsBaseinfoService.createWsBaseinfo(wsBaseinfoBaseVO);
//                } else {
//                    wsBaseinfoService.updateWsBaseinfo(wsBaseinfoBaseVO);
//                }
                break;
            case T_ENTUSER:
                EntuserUpdateReqVO entuserUpdateReqVO = (EntuserUpdateReqVO) data.toBean(target.getCls());
                if (type == ChangeInfoNotificationEnum.Type.INSERT) {
                    entuserService.createEntuser(entuserUpdateReqVO);
                } else {
                    entuserService.updateEntuser(entuserUpdateReqVO);
                }
                break;
            case T_MARPRIPINFO:
                MarpripinfoBaseVO marpripinfoBaseVO = (MarpripinfoBaseVO) data.toBean(target.getCls());
                if (type == ChangeInfoNotificationEnum.Type.INSERT) {
                    marpripinfoService.createMarpripinfo(marpripinfoBaseVO);
                } else {
                    marpripinfoService.updateMarpripinfo(marpripinfoBaseVO);
                }
                break;
        }
    }
}
